using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Telerik.Web.UI;

public partial class Posts2 : BasePostPage
{
    public override Acms.Bll.Role.Roles[] AllowedRoles
    {
        get { return new Acms.Bll.Role.Roles[] { Acms.Bll.Role.Roles.Developer, Acms.Bll.Role.Roles.ContentEditor, Acms.Bll.Role.Roles.ContentViewer, Acms.Bll.Role.Roles.UserGeneratedContentEditor}; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dsSiteMap.SiteId = AcmsSite.Id;
            tvSiteMap.DataBind();
        }
        tvSiteMap.ContextMenuItemClick += new RadTreeViewContextMenuEventHandler(tvSiteMap_ContextMenuItemClick);
    }

    void tvSiteMap_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    {
        Page.Trace.Warn("ContextMenuItemID", e.MenuItem.ID);
        Page.Trace.Warn("ContextMenuItemText", e.MenuItem.Text);
        Page.Trace.Warn("NodeClicked", e.Node.Value);
    }

    protected void tvSiteMap_NodeDataBound(object sender, RadTreeNodeEventArgs e)
    {
        tvSiteMap.NodeDataBound += new RadTreeViewEventHandler(tvSiteMap_NodeDataBound);
        RadTreeViewContextMenu cm = new RadTreeViewContextMenu();

        cm.ID = string.Concat(e.Node.Value, "_cm");
        e.Node.ContextMenuID = cm.ID;

        RadMenuItem details = new RadMenuItem();
        details.Value = "Details";
        details.Text = "Details";
        cm.Items.Add(details);

        RadMenuItem contents = new RadMenuItem();
        contents.Value = "Contents";
        contents.Text = "Contents";
        cm.Items.Add(contents);

        RadMenuItem move = new RadMenuItem();
        move.Value = "Move";
        move.Text = "Move";
        move.PostBack = true;
        cm.Items.Add(move);

        /*cm.Items.Add(new RadTreeViewContextMenu());

        List<Acms.Bll.Template> templates = Acms.Bll.Template.GetAllBySiteId(AcmsSite.Id);
        foreach (Acms.Bll.Template t in templates)
        {
            RadTreeViewContextMenu.ContextMenuItem child = new RadTreeViewContextMenu.ContextMenuItem();
            child.ID = string.Format("Child_{0}", t.Id);
            child.Text = string.Format("Add {0} Child", t.Name);
            child.PostBack = true;
            cm.Items.Add(child);
        }

        cm.Items.Add(new RadTreeViewContextMenu.ContextMenuItem());

        foreach (Acms.Bll.Template t in templates)
        {
            RadTreeViewContextMenu.ContextMenuItem child = new RadTreeViewContextMenu.ContextMenuItem();
            child.ID = string.Format("Sibling_{0}", t.Id);
            child.Text = string.Format("Add {0} Sibling", t.Name);
            child.PostBack = true;
            cm.Items.Add(child);
        }
        */
        tvSiteMap.ContextMenus.Add(cm);
            
    }

}
